<%@ page language="java" contentType="text/html;charset=utf-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions"%>
<%@page import="cn.jdy.framework.util.IpUtil"%>
<%
	String ip =IpUtil.getIp(request);// 访问者IP
	request.setAttribute("ipaddress", ip);
	%>

<!DOCTYPE html>
<!--[if IE 8]> <html lang="en" class="ie8 no-js"> <![endif]-->
<!--[if IE 9]> <html lang="en" class="ie9 no-js"> <![endif]-->
<!--[if !IE]><!-->
<html lang="en" class="no-js">
<!--<![endif]-->
<head>
<jsp:include page="../common/common.jsp" />
</head>
<body class="page-header-fixed">
	<jsp:include page="../common/header.jsp" />
	<div class="clearfix"></div>
	<div class="page-container">
		<div class="page-sidebar-wrapper"><jsp:include
				page="../common/menu.jsp" /></div>
		<div class="page-content-wrapper">
			<div class="page-content">
				<div class="row">
					<div class="col-md-12">
						<form class="form-horizontal form-row-seperated" id="form"
							method="post" action="${path}/lhkgajeverymouth/save">
							<div class="portlet box purple">
								<div class="portlet-title">
									<div class="caption">
										<i class="fa fa-shopping-cart"></i>材料管理详细内容
									</div>
									<div class="actions btn-set">
										<input class="btn default" type="button" value="取消" onclick="javascript:history.go(-1);"> 
<!-- 										<button type="button" onclick="saveOk()" -->
<!-- 											class="btn  btn-success"> -->
<!-- 											<i class="fa fa-check"></i> 有效 -->
<!-- 										</button> -->
<!-- 										<button type="button" onclick="saveRm()" -->
<!-- 											class="btn btn-warning"> -->
<!-- 											<i class="fa icon-lock"></i> 无效 -->
<!-- 										</button> -->
										<button type="button" onclick="save()" class="btn blue">
											<i class="fa fa-check"></i> 保存
										</button>

									</div>
								</div>
								<div class="portlet-body">
									<div class="tabbable">
										<div class="tab-content no-space">
											<div class="tab-pane active" id="tab_general">
												<div class="form-body">
													<div class="form-group">
														<label class="col-md-2 control-label">材料编号: <span
															class="required">*</span>
														</label>

														<div class="col-md-5">
															<input type="text" id="value1" name="value1"
																class="form-control measure-input" 
																value="${data.value1}" />
														</div>
													</div>
													<div class="form-group">
														<label class="col-md-2 control-label">材料名称: <span
															class="required">*</span>
														</label>

														<div class="col-md-5">
															<input type="text" id="value2" name="value2"
																class="form-control measure-input" datatype="*1-80"
																value="${data.value2}" />
														</div>
														<div class="col-md-5">
															&nbsp;可输入<b><span id="title_len">80</span></b> 个字符 &nbsp;
															
														</div>
													</div>
													<div class="form-group">
														<label class="col-md-2 control-label">状态: <span
															class="required">*</span>
														</label>
														<div class="col-md-5">
															<select name="openStatus" class="form-control">
																<!--                                                             <option value="1" <c:if test="${1== data.status }">selected="selected" </c:if> >有效</option> -->
																<!--                                                             <option value="0" <c:if test="${0== data.status }">selected="selected" </c:if> >无效</option> -->
																<!--                                                             <option value="3" <c:if test="${3== data.status }">selected="selected" </c:if> >置顶</option> -->
																<option value="1"
																	<c:if test="${1== data.openStatus }">selected="selected" </c:if>>入库</option>
																<option value="2"
																	<c:if test="${2== data.openStatus }">selected="selected" </c:if>>出库</option>
																<option value="3"
																	<c:if test="${3== data.openStatus }">selected="selected" </c:if>>维修</option>
															</select>
														</div>
														<div class="col-md-5">
<!-- 															&nbsp;可输入<b><span id="title_len">80</span></b> 个字符 &nbsp; -->
															
														</div>
													</div>
												</div>
												<div class="form-group">
													<label class="col-md-2 control-label">发布时间: </label>

													<div class="col-md-5">
														<input id="falseCreateTime" name="falseCreateTime"
															type="text" class="form-control tags medium"
															value="${fn:substring(data.falseCreateTime,0,19)}" onclick="WdatePicker({dateFmt:'yyyy-MM-dd HH:mm:ss'})"/>
													</div>
												</div>
												<div class="form-group">
														<label class="col-md-2 control-label">使用工区: <span
															class="required">*</span>
														</label>

														<div class="col-md-5">
															<input type="text" id="value4" name="value4"
																class="form-control measure-input" 
																value="${data.value4}" />
														</div>
													</div>
													<div class="form-group">
														<label class="col-md-2 control-label">使用车间: <span
															class="required">*</span>
														</label>

														<div class="col-md-5">
															<input type="text" id="value5" name="value5"
																class="form-control measure-input" 
																value="${data.value5}" />
														</div>
													</div>
													<div class="form-group">
														<label class="col-md-2 control-label">型号规格: <span
															class="required">*</span>
														</label>

														<div class="col-md-5">
															<input type="text" id=value6 name="value6"
																class="form-control measure-input" 
																value="${data.value6}" />
														</div>
													</div>
													<div class="form-group">
														<label class="col-md-2 control-label">生产厂家: <span
															class="required">*</span>
														</label>

														<div class="col-md-5">
															<input type="text" id="value7" name="value7"
																class="form-control measure-input" 
																value="${data.value7}" />
														</div>
													</div>
													<div class="form-group">
														<label class="col-md-2 control-label">材料价格: <span
															class="required">*</span>
														</label>

														<div class="col-md-5">
															<input type="text" id="value8" name="value8"
																class="form-control measure-input" 
																value="${data.value8}" />
														</div>
													</div>
													<div class="form-group">
														<label class="col-md-2 control-label">储位编号: <span
															class="required">*</span>
														</label>

														<div class="col-md-5">
															<input type="text" id="value9" name="value9"
																class="form-control measure-input" 
																value="${data.value9}" />
														</div>
													</div>
													<div class="form-group">
														<label class="col-md-2 control-label">备注: <span
															class="required">*</span>
														</label>

														<div class="col-md-5">
															<textarea id="value10" name="value10"
                                                               class="form-control tags medium" style="height: 200px ! important;width: 600px ! important;"
                                                               >${data.value10}</textarea>
														</div>
													</div>
										<%-- 		<div class="form-group">
													<label class="col-md-2 control-label">URL: </label>

													<div class="col-md-5">
														<input id="isURL" name="isURL" type="text"
															class="form-control tags medium" value="${data.isURL}" />
													</div>
												</div>
												
												<input type="hidden" name="author" class="form-control"
													value="admin" /> <input type="hidden" id="imgUrl"
													name="imgUrl" class="form-control" value="${data.imgUrl}" />

												
												<div class="form-group">
													<label class="col-md-2 control-label">封面：</label>

													<div class="col-md-8">
														<div class="fileinput fileinput-new"
															data-provides="fileinput">
															<div class="fileinput-new thumbnail"
																style="width: 300px; height: 150px;">
																<img src="${data.imgUrl}">
															</div>
															<div class="fileinput-preview fileinput-exists thumbnail"
																style="max-width: 300px; max-height: 150px;"></div>
															<div>
																<span class="btn default btn-file"> <span
																	class="fileinput-new"> 选择图片 </span> <span
																	class="fileinput-exists"> 修改图片 </span> <input
																	type="file" id="file" name="file" />
																</span> <a href="#" class="btn default fileinput-exists"
																	data-dismiss="fileinput"> 移除图片 </a>
															</div>
														</div>
													</div>
												</div>
												
												<div class="form-group">
													<label class="col-md-2 control-label">个人信息: </label>

													<div class="col-md-5">
														<input id="isSigned" name="isSigned" type="text"
															class="form-control tags medium" value="${data.isSigned}" />
													</div>
												</div>
												<div class="form-group">
                                                    <label class="col-md-2 control-label">投稿人:    
                                                    </label>
                                                     <div class="col-md-3">
                                                  <select id="department" name="department" class="form-control">
                                                  <option value="">当前用户 </option>
                                                    <c:forEach items="${deptList}" var="d">
                                                            <option value="${d.value3 }"<c:if test="${d.value3==data.department }">selected="selected"</c:if>>${d.value0}</option>
                                                        </c:forEach>
                                                        </select></div>
                                                </div>
												<div class="form-group">
													<label class="col-md-2 control-label">内容: <span
														class="required">*</span>
													</label>

													<div class="col-md-8">
														<input id="context" type="hidden" name="context">
														<script id="editor" type="text/plain"
															style="height:500px;">${data.context}</script>
													</div>
												</div>
												
												 <div class="form-group">
                                                		<label class="col-md-2 control-label">是否签收:
                                                        <span class="required">*</span>
	                                                    </label>
	                                                    <div class="col-md-3">
	                                                        <select name="isSignNews" class="form-control">
	                                                            <option value="0" <c:if test="${0== data.isSignNews }">selected="selected" </c:if> >不签收</option>
	                                                        	<option value="1" <c:if test="${1== data.isSignNews }">selected="selected" </c:if> >签收</option>
	                                                        </select>
	                                                    </div>
                                                </div>
                                                
                                                <div class="form-group">
														<label class="col-md-2 control-label">签收单位: <span
															class="required">*</span>
														</label>
														<script type="text/javascript">
														//全选 全不选
														function selectAll(){  
														    if ($("#SelectAll").attr("checked")) {  
														        $(":checkbox").attr("checked", true);  
														    } else {  
														        $(":checkbox").attr("checked", false);  
														    }  
														}  
														
														
														//获取所有东津的签收单位
														$(function(){
														  var dwsName = '${data.signDepartment}';
														  $.ajax({										
															    url: _path + "/userColumn/listDjQsdw",
															    type: "POST",
															    dataType: "json",
															    async: false,
															    success: function(jsonMap) {
															    	var list = jsonMap.dataList;
															    	$("#dwInfo").html("");
															        if(list.length>0){
															        	if(null == dwsName){  //添加时获取所有单位
															        		for(var i=0;i<list.length;i++){
																				var dw = list[i];
																				var dInfo = "<label><input type='checkbox' name='ck' value="+dw.value3+">"+dw.value0+"</label>&nbsp;&nbsp;";
																				$("#dwInfo").append(dInfo);
																        	}
															        	}else{  //修改时 比对判断单位是否被选中
															        		for(var i=0;i<list.length;i++){
																				var dw = list[i]; 
																				var names = dwsName.split(";"); 
																				var dInfo = "<label><input type='checkbox' name='ck' value="+dw.value3+">"+dw.value0+"</label>&nbsp;&nbsp;";
																				for(var j=0;j<names.length;j++){
																					var localDw = names[j];
																					if(dw.value3 == localDw){
																						dInfo="<label><input type='checkbox' name='ck' checked value="+dw.value3+">"+dw.value0+"</label>&nbsp;&nbsp;";
																					}
																				}
																				$("#dwInfo").append(dInfo);
																        	}
															        	}
															        	
															        }
															    }
															});
														});
														
														
															var cnt = 49;
															var radiostate = 0;
															function radioChangeRed() {
																if (radiostate == 1) {
																	document.getElementById('isRed').checked = false;
																	radiostate = 0;
																} else {
																	document.getElementById('isRed').checked = true;
																	radiostate = 1;
																}
															}
															function radioChangeNews() {
																if (radiostate == 1) {
																	document.getElementById('isNews').checked = false;
																	radiostate = 0;
																} else {
																	document.getElementById('isNews').checked = true;
																	radiostate = 1;
																}
															}
															
															
														</script>
														<div class="col-md-3" style="width:640px;">
															<div style="float: left;">
																<span style="color:red;font-size: 18px;">【全选】</span> 
																<label>
																	<input type="checkbox" id="SelectAll"  onclick="selectAll();">
																</label><br>
																<div style="float:left;margin-left:60px;"  id="dwInfo"></div>
															</div>
														</div>  --%>
														
														
													</div>
												
											</div>
										</div>
									</div>
<!-- 								</div> -->


								<div class="portlet-title">
									<div class="actions btn-set">
										<input class="btn default" type="button" value="取消" onclick="javascript:history.go(-1);"> 



<!-- 										<button type="button" onclick="saveOk()" -->
<!-- 											class="btn  btn-success"> -->
<!-- 											<i class="fa fa-check"></i> 有效 -->
<!-- 										</button> -->
<!-- 										<button type="button" onclick="saveRm()" -->
<!-- 											class="btn btn-warning"> -->
<!-- 											<i class="fa icon-lock"></i> 无效 -->
<!-- 										</button> -->
										
										<button type="button" onclick="save()" class="btn blue">
											<i class="fa fa-check"></i> 保存
										</button>
									</div>
								</div>
							</div>
					</div>
					<input type="hidden"   id="id" name="id" value="${data.id}">
					<input type="hidden" id=iseverymouth name="iseverymouth" value="${data.iseverymouth==null?1:data.iseverymouth}">
					<input type="hidden" id=iscolums name="iscolums" value="${data.iscolums==null?0:data.iscolums}">
					<input type="hidden" id=columnId name="columnId" value="${data.columnId==null?10655:data.columnId}"> 
					<input type="hidden" name="topTime" id="topTime" value="${data.topTime==null?0:data.topTime}" /> 
					<input type="hidden" name="readTimes" id="readTimes" value="${data.readTimes}" /> 
					<input type="hidden" id="status" name="status" value="${data.status==null?1:data.status}" /> 
					<input type="hidden" id="zisNews" name="isNews" value="${data.isNews==null?1:data.isNews}" /> 
					<input type="hidden" id="username" name="username" value="${data.username}">
					<input type="hidden" name="isarticle"  id="isarticle"  value="0"  /> 
					<input type="hidden" id="teams" name="teams" value="${ipaddress}" />
					<c:if test="${data.signStatus!=null}">
								<input type="hidden" name="signStatus" id="signStatus"
									value="${data.signStatus}" />
					</c:if>
  	                <input type="hidden" id="signDepartment" name="signDepartment" >
  	                <input type="hidden" id="summary" name="summary" value="${user.username}">
					</form>
				</div>
			</div>
		</div>
	</div>
	</div>
<%-- 	<script type="text/javascript">
		var radiostate = 0;
		function radioChangeNews(em) {
			var v = $(em).val();
			if (v == "1") {
				document.getElementById('isNews').checked = false;
				$(em).val("0");
				$("#zisNews").val("0");
			} else {
				document.getElementById('isNews').checked = true;
				$(em).val("1");
				$("#zisNews").val("1");
			}

		}
	</script>  --%>
	<jsp:include page="../common/footer.jsp" />
	<script type="text/javascript" src="${path}/assets/plugins/calendar/WdatePicker.js"></script>
	<script type="text/javascript"
		src="${path}/assets/plugins/bootstrap-fileinput/bootstrap-fileinput.js"></script>
	<script type="text/javascript"
		src="${path}/assets/plugins/jquery-inputmask/jquery.inputmask.bundle.min.js"></script>
	<script type="text/javascript"
		src="${path}/assets/plugins/jquery.input-ip-address-control-1.0.min.js"></script>
	<script type="text/javascript"
		src="${path}/assets/plugins/jquery.pwstrength.bootstrap/src/pwstrength.js"></script>
	<script type="text/javascript"
		src="${path}/assets/scripts/biz/ajaxfileupload.js"></script>
<!-- 	<script type="text/javascript" -->
<!-- 		src="${path}/assets/plugins/ueditor/ueditor.config.js"></script> -->
<!-- 	<script type="text/javascript" -->
<!-- 		src="${path}/assets/plugins/ueditor/ueditor.all.min.js"></script> -->
<!-- 	<script type="text/javascript" -->
<!-- 		src="${path}/assets/plugins/ueditor/lang/zh-cn/zh-cn.js"></script> -->
	<script type="text/javascript"
		src="${path}/assets/plugins/district/linkagesel-min.js"></script>
	<script type="text/javascript" src="${path}/operate/js/topDz.js"></script>
	<script>
		var operType = '${operType}';
		var editor, form;

		$(function() {

			//UE.getEditor('editor');
			form = $("form").Validform({
				tiptype : function(msg, o, cssctl) {
					//msg：提示信息;
					//o:{obj:*,type:*,curform:*}, obj指向的是当前验证的表单元素（或表单对象），type指示提示的状态，值为1、2、3、4， 1：正在检测/提交数据，2：通过验证，3：验证失败，4：提示ignore状态, curform为当前form对象;
					//cssctl:内置的提示信息样式控制函数，该函数需传入两个参数：显示提示信息的对象 和 当前提示的状态（既形参o中的type）;
					if (!o.obj.is("form")) {//验证表单元素时o.obj为该表单元素，全部验证通过提交表单时o.obj为该表单对象;
						var objtip = o.obj.siblings(".Validform_checktip");
						cssctl(objtip, o.type);
						objtip.text(msg);
					} else {
						var objtip = o.obj.find("#msgdemo");
						cssctl(objtip, o.type);
						objtip.text(msg);
					}
				},
				postonce : true,
				showAllError : true,
				callback : function() {
					save();
				}
			});
		});
		//选择文章状态
// 		function seleceStatus(em) {

// 			$('[name="status"]').val($(em).val());
// 		}
		//设置这个文章有效
// 		function saveOk() {
// 			$('[name="status"]').val("1");
// 			save();
// 		}
		//设置这个文章无效
// 		function saveRm() {
// 			$('[name="status"]').val("8");
// 			save();
// 		}
		//取消设置这个文章封面
// 		function saveRmimg() {
// 			$('[name="imgUrl"]').val("");
// 			save();
// 		}
		//设置置顶
// 		function saveDz() {
// 			$('[name="topTime"]').val("1");
// 			save();
// 		}
		//取消设置置顶
// 		function saveRmdz() {
// 			$('[name="topTime"]').val("0");
// 			save();
// 		}
		//设置公安要闻第一
// 		function saveYwdy() {
// 			$('[name="status"]').val("3");
// 			save();
// 		}
		//取消设置公安要闻第一
// 		function saveRmYwdy() {
// 			$('[name="status"]').val("1");
// 			save();
// 		}
		function save() {
// 			var context = UE.getEditor('editor').getContent();
// 			if (!/[\w\W]+/.test(context)) {
// 				alert("内容不能为空");
// 				return;
// 			}
// 			$("#context").val(context);
			
// 			获取签收单位	
// 			var qsdw = "";
// 			var ckValues = document.getElementsByName("ck");   
// 			for(var i=0;i<ckValues.length;i++){
// 				if(ckValues[i].checked==true){
// 					qsdw = qsdw+ckValues[i].value+";";
// 				}
// 			}
			
// 			alert("当前签收单位"+qsdw);
// 			if(qsdw != ""){
// 				$("#signDepartment").val(qsdw);
// 			}

		/*	if ($("#file").val() !== "") {
				$.ajaxFileUpload({
					url : '${path}/conf/upload',
					secureuri : false,
					fileElementId : 'file',
					dataType : 'json',
					success : function(data, status) {
						if (data.statusCode == 200) {
							$("#imgUrl").val(data.uri);

							App.ajax(_path + "/lhkgajeverymouth/save", $("form")
									.serialize(), function(data) {
								if (data.statusCode == 200) {
									App.bubble(200, "更新成功！");
									window.setTimeout(function() {
										window.close();//修改成功，弹出新页面，直接关闭
									}, 400);
								} else if (data.statusCode == 100) {
									App.bubble(100, "添加成功！");
									window.setTimeout(function() {
										//history.go(-1);//返回上一级
										window.close();
									}, 400);
								} else {
									App.bubble(500, "信息失败！");
									// alert("信息失败")
								}
							});

							//                         $("#form").submit();
						} else
							alert(data.info);
					}
				});
			} else { */
				App.ajax(_path + "/lhkgajeverymouth/save", $("form").serialize(),
						function(data) {
							if (data.statusCode == 200) {
								App.bubble(200, "更新成功！");
								window.setTimeout(function() {
									//window.close();//修改成功，弹出新页面，直接关闭
									history.go(-1);
								}, 400);
							} else if (data.statusCode == 100) {
								App.bubble(100, "添加成功！");
								window.setTimeout(function() {
									history.go(-1);//返回上一级
									//window.close();
								}, 400);
							} else {
								App.bubble(500, "信息失败！");
								// alert("信息失败")
							}
						});

				// 	        $("#form").submit();
			//}

		}
// 		$(function() {
// 			var isn = $("#zisNews").val()
// 			if (isn == '1') {
// 				$("#isNews").attr("checked", "true");
// 			} else if (isn == '0') {
// 				$("#isNews").removeAttr("checked");
// 			}
// 		});
	</script>
</body>
</html>